﻿@model List<SenFangKaoHe_MVC.Models.Entity.kaohe>;
@{
    Layout = null;
    ViewData["Title"] = "查询考核信息";
}
<script src="/js/jquery-3.7.1.min.js"></script>
<link rel="stylesheet" href="~/css/ShiJuanStyle.css" />
<div id="info">
    <div id="info1">
        <div style="text-align:center">
            
        </div>
            <div id="kaohediv">
        </div>
        <div>
            <div id="lianxidiv">
        </div>
    </div>
</div>

<script>
    $(document).ready(function(){

            $.ajax({
                   url: "Home/getKaoHes",    //后台数据请求地址
                   type: "get",
                   dataType: 'json',
                   traditional: true,
                   data:{
                   },
                   async: true,
                   success: function (resut) {
                       console.log(resut);
                       var _html = "";
                       if(resut.length>0){  //如果有数据，就显示
                                _html += "<input type='text' style='text-align:center;' id='xm' name='xm' placeholder='请输入查询人员姓名' /><br /><br />";
                                _html += "<input type='button' value='查询考核信息' onclick='myclick()' />";
                           
                       }
                       else{  //没数据，显示暂无考核项目
                           _html = "<br />暂无考核项目";
                           _html += "<br /><input type='button' value='模拟练习' onclick='monilianxi()'/>";
                       }
                       $("#kaohediv").html(_html);
                   }
              });
    });
</script>

<script>
    function myclick(){
       var xm = $("#xm").val();
       if(xm == ""){
           alert("请输入姓名！");
           return;
       }else{
           console.log("xm:"+xm);
           $.ajax({
               url: "Home/getKaoHe",    //后台数据请求地址
               type: "get",
               dataType: 'json',
               traditional: true,
               data:{
                   xm: xm    //参数传递
               },
               async: true,
               success: function (resut) {
                  console.log(resut);
                  var lxhtml = "";
                   if(resut.length>0){  //如果有数据，就显示
                        var _html = "<br /><table><tr><td>序号</td><td>考核名称</td><td>截至日期</td><td>考核信息</td></tr>";
                        for(var i = 0;i<resut.length;i++){
                            //看是否有考核成绩
                            if(resut[i].shijuans.length >0){   //有成绩
                                _html += "<tr><td>"+(i+1)+"</td><td>"+resut[i].mingCheng+"</td><td>"+resut[i].riQi.split('T')[0]+"</td><td>理论成绩："+resut[i].shijuans[0].chengji+"分<br />绩效得分："+resut[i].shijuans[0].fenzhi+"分</td></tr>";
                            }else{   //无成绩
                                _html += "<tr><td>"+(i+1)+"</td><td>"+resut[i].mingCheng+"</td><td>"+resut[i].riQi.split('T')[0]+"</td><td><input type='button' value='参与考核' onclick='startkaohe("+resut[i].id+")'style='margin:10px;' /></td></tr>";
                            }
                        }
                        _html += "</table>"
                   }
                       $("#lianxidiv").html(_html);
               }
          });
       }
    }
</script>

<script>
    function startkaohe(_khid){
        if($("#xm").val() == ""){
            alert("请输入姓名！");
            return;
        }else{
            var url = "/KaoShi/KaoShi?khid="+_khid+"&xm="+$("#xm").val();
            window.location.href =url;
        }
    }
</script>

<script>
    function monilianxi(){
        var url = "/LianXi/Index";
        window.location.href = url;
    }
</script>

